<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>RStudio Server</title>
  <style id="page-style">
    #banner {
      margin-bottom: 0;
    }
    p {
      margin: 20px 40px 10px 40px;
    }
    ul {
      margin-left: 40px;
    }
  </style>
</head>

<body>
  <header role="banner">
    <div id="banner">
      <picture>
        <source
          id="logo-reverse"
          srcset="images/Posit-ProductLogo_rst-server-reverse.svg"
          media="(prefers-color-scheme: dark)"
        />
        <img
          id="logo-full-color"
          src="images/Posit-ProductLogo_rst-server-full-color.svg"
          height="27"
          alt="RStudio Logo"
        />
      </picture>
      <div style="flex: 1"></div>
      <form method="post" id="signOutForm" action="auth-sign-out">
        <input type="hidden" name="rs-csrf-token" id="rs-csrf-token" />
        <span class="username">
          #!username#
          <input type="image" alt="Sign Out" id="signOut" src="images/signOut.png" />
        </span>
      </form>
    </div>
  </header>
  <div id="view" class="container">

    <p>
      RStudio encountered an error and the request could not be processed:
    </p>

    <ul>
      <li><b>#error_description#</b></li>
    </ul>
    <ul>
      <li><b>#error_message#</b></li>
    </ul>

    <p>
      Please contact your system administrator for assistance, or click
      <a id="url" href="#" onClick="history.back();">here</a> to go back.
    </p>
  </div>
  <script>
    function getBaseUri() {
      var baseUri = "#!base_uri#";
      if (!baseUri) {
        baseUri = window.location.href;
      }
      var index = baseUri.lastIndexOf("#!request_uri#");
      if (index > 0) {
        return baseUri.substring(0, index);
      }
      return "";
    }

    var style = document.getElementById("page-style");

    var cssLink = document.createElement("link");
    cssLink.href = getBaseUri() + "/css/page.css";
    cssLink.type = "text/css";
    cssLink.rel = "stylesheet";
    style.insertAdjacentElement("beforebegin", cssLink);

    cssLink = document.createElement("link");
    cssLink.href = getBaseUri() + "/rstudio.css";
    cssLink.type = "text/css";
    cssLink.rel = "stylesheet";
    style.insertAdjacentElement("beforebegin", cssLink);

    var iconLink = document.createElement("link");
    iconLink.href = getBaseUri() + "images/Posit-Product_rst-server-favicon.svg";
    iconLink.rel = "shortcut icon";
    style.insertAdjacentElement("beforebegin", iconLink);

    document.getElementById("logo-reverse").srcset = getBaseUri() + "/images/Posit-ProductLogo_rst-server-reverse.svg";
    document.getElementById("logo-full-color").src = getBaseUri() + "/images/Posit-ProductLogo_rst-server-full-color.svg";

    document.getElementById("signOutForm").action = getBaseUri() + "/auth-sign-out";
    document.getElementById("signOut").src = getBaseUri() + "/images/signOut.png";
    document.getElementById("url").href = getBaseUri() + "/home";

    document.getElementById("rs-csrf-token").value = document.cookie.match(RegExp("(?:^|;\\s*)rs-csrf-token=([^;]*)"))[1];
  </script>
</body>
</html>
